package com.ebt.m.users;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.ebt.m.R;
import com.ebt.m.commons.buscomponent.listview.IView;
import com.ebt.m.commons.utils.Logger;
import com.ebt.m.users.bean.CardService;

import butterknife.BindView;
import butterknife.ButterKnife;

public class CardServiceView extends IView {


    @BindView(R.id.service_img)
    ImageView serviceImg;
    @BindView(R.id.service_title)
    TextView serviceTitle;
    @BindView(R.id.service_date)
    TextView serviceDate;
    @BindView(R.id.service_content)
    TextView serviceContent;
    @BindView(R.id.item_root)
    LinearLayout itemRoot;

    public CardServiceView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        inflate(context, R.layout.layout_carddata_service, this);
        ButterKnife.bind(this);
    }

    public CardServiceView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CardServiceView(Context context) {
        this(context, null);
    }

    @Override
    public void update(Object... obj) {
        try {
            CardService cardService = (CardService) obj[0];
            serviceTitle.setText(cardService.getTitle());
            serviceDate.setText(cardService.getDate());
            serviceContent.setText(cardService.getDescription());
            Glide.with(getContext())
                    .load(cardService.getImgAddress())
                    .error(R.drawable.empty_photo)
                    .dontAnimate()
                    .into(serviceImg);
        } catch (Exception e) {
            Logger.e(e);
        }

    }


}
